import axios from 'axios'
// 引入公共参数
import {commonParams} from './config'

// 获取轮播图片
export function getRecommend () {
  return axios({
    method: 'get',
    url: '/api/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'
  })
}

// 获取推荐歌单
export function getDiscList () {
  // const url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg'
  const url = '/api/getDiscList'
  const data = Object.assign({}, commonParams, {
    // 以下参数自行参考源json文件的Query String Parameters
    platform: 'yqq',
    uin: 0,
    needNewCode: 0,
    hostUin: 0,
    sin: 0,
    ein: 29,
    sortId: 5,
    rnd: Math.random(),
    categoryId: 10000000,
    format: 'json'
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取推荐歌单详情列表
export function getSongList (disstid) {
  const url = '/api/getSongList'

  const data = Object.assign({}, commonParams, {
    disstid,
    type: 1,
    json: 1,
    g_tk: 808397969,
    utf8: 1,
    onlysong: 0,
    new_format: 1,
    platform: 'yqq.json',
    hostUin: 0,
    needNewCode: 0,
    format: 'json',
    inCharset: 'utf8'
  })

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res)
  })
}
